草庐IT

从 Navigator 到 MaterialApp 的 routeSettings flutter

全部标签

Flutter BLoC : Navigator. 在 build() 方法中弹出 StreamBuilder

我正在遵循BLoC模式并订阅流,并对构建方法中的状态变化使用react。加载数据后,我想关闭屏幕。@overrideWidgetbuild(BuildContextcontext){returnScaffold(appBar:AppBar(title:constText('Bloc'),),body:SafeArea(child:StreamBuilder(stream:_userBloc.user,initialData:UserInitState(),builder:(context,snapshot){if(snapshot.dataisUserInitState){return

flutter - WillPopScope 我应该在 Navigator.pop 之后使用 return Future.value(true)

在Navigator.pop(context)之后使用returnFuture.value(false);是正确的方法。如果我使用Navigator.pop(context,false)之后返回Future.value(true);应用程序在按下后退按钮后将显示黑屏,并且Logcat中没有错误。但是如果我使用没有Navigator.pop(context)或没有returnFuture.value(true);的相同代码,一切都会好起来的,使用returnFuture.value(false);也可以正常工作。*遵循Udemy上显示returnFuture.value(true)的教程

flutter - WillPopScope 我应该在 Navigator.pop 之后使用 return Future.value(true)

在Navigator.pop(context)之后使用returnFuture.value(false);是正确的方法。如果我使用Navigator.pop(context,false)之后返回Future.value(true);应用程序在按下后退按钮后将显示黑屏,并且Logcat中没有错误。但是如果我使用没有Navigator.pop(context)或没有returnFuture.value(true);的相同代码,一切都会好起来的,使用returnFuture.value(false);也可以正常工作。*遵循Udemy上显示returnFuture.value(true)的教程

flutter - 如何关闭 Navigator.of(context).overlay

用我的代码:finalCustomOverlaycustomOverlay=newCustomOverlay();Navigator.of(context).overlay.insert(OverlayEntry(builder:(BuildContextcontext){returncustomOverlay;}));但是当我想关闭那个customOverlay但我不知道如何......我尝试了Navigator.of(context).overlay.dispose();但这行不通....[✓]Flutter(Channelstable,v1.0.0,onMacOSX10.13.6

flutter - 如何关闭 Navigator.of(context).overlay

用我的代码:finalCustomOverlaycustomOverlay=newCustomOverlay();Navigator.of(context).overlay.insert(OverlayEntry(builder:(BuildContextcontext){returncustomOverlay;}));但是当我想关闭那个customOverlay但我不知道如何......我尝试了Navigator.of(context).overlay.dispose();但这行不通....[✓]Flutter(Channelstable,v1.0.0,onMacOSX10.13.6

dart - 在我的 flutter 应用程序中使用 StreamBuilder 和 Navigator,但第一页构建了两次

伙计们。我正在使用StreamBuilder处理异步数据。这是一个演示,在第一页上有一个按钮,点击该按钮将导航到第二页。完整代码如下。import'package:flutter/material.dart';import'dart:async'showStreamController;voidmain(){runApp(newMaterialApp(title:'FirstPage',theme:newThemeData(primarySwatch:Colors.blue,),home:newFirstPage(),),);}classFirstPageextendsStateles

dart - 在我的 flutter 应用程序中使用 StreamBuilder 和 Navigator,但第一页构建了两次

伙计们。我正在使用StreamBuilder处理异步数据。这是一个演示,在第一页上有一个按钮,点击该按钮将导航到第二页。完整代码如下。import'package:flutter/material.dart';import'dart:async'showStreamController;voidmain(){runApp(newMaterialApp(title:'FirstPage',theme:newThemeData(primarySwatch:Colors.blue,),home:newFirstPage(),),);}classFirstPageextendsStateles

android - 如何修复 flutter 异常 : Navigator operation requested with a context that does not include a Navigator

我正在尝试使用flutter框架创建抽屉导航,但是我每次运行它都会遇到以下异常Anotherexceptionwasthrown:NavigatoroperationrequestedwithacontextthatdoesnotincludeaNavigator.那么解决方案是什么,有什么帮助吗?我使用Navigator类如下voidmain(){runApp(newMyApp());}classMyAppextendsStatefulWidget{@overrideStatecreateState(){//TODO:implementcreateStatereturnnewAppS

android - 如何修复 flutter 异常 : Navigator operation requested with a context that does not include a Navigator

我正在尝试使用flutter框架创建抽屉导航,但是我每次运行它都会遇到以下异常Anotherexceptionwasthrown:NavigatoroperationrequestedwithacontextthatdoesnotincludeaNavigator.那么解决方案是什么,有什么帮助吗?我使用Navigator类如下voidmain(){runApp(newMyApp());}classMyAppextendsStatefulWidget{@overrideStatecreateState(){//TODO:implementcreateStatereturnnewAppS

Flutter MaterialApp Widget 参数中的本地化

按照1上的教程进行操作和2我正在尝试为我的flutter应用程序设置本地化。效果很好,我可以使用I18n.of(context).trans()访问我的小部件中的翻译字符串。但是我不知道如何访问MaterialApp中的翻译顶部小部件:import'package:flutter/material.dart';import'package:flutter_app/i18n/i18n.dart';import'package:flutter_app/views/menu.dart';import'package:flutter\_localizations/flutter\_locali